Flash Article

Creating Movie Clip Subclasses in ActionScript 2.0


Brian Lesser

Brian Lesser
Ryerson University

Table of Contents

  1. Introduction
  2. Classes and Objects, Symbols and Clips
  3. A Short History of Movie Clip Behaviors
  4. Tutorial 1: Using a Movie Clip Subclass to Make a Bouncing Ball Animation
  5. Tutorial 2: Creating a More Extensive Grab-and-Match Puzzle

ActionScript 2.0 makes it easy to create movie clips with predefined behaviors—even easier than it is using ActionScript 1.0. Not only do you not have to use the prototype object at all but the association between your class and a movie clip in the library is created by filling in a field in the authoring environment. This tutorial shows you how to write ActionScript 2.0 classes that define the behavior of movie clips in the library. It is based on my previous article "Creating Movie Clip Subclasses," which describes using ActionScript 1.0 in Macromedia Flash MX to do the same thing.

Just as my first tutorial shows you how to do a simple scripted animation and proceeds to a somewhat more complex puzzle game, this tutorial revisits the same animation and game using ActionScript 2.0. Everything I demonstrate here you can still do using ActionScript 1.0 in Macromedia Flash MX 2004 and Macromedia Flash MX Professional 2004. So what's different? The code in this tutorial is less cluttered and, in the case of the game, does a little more than the previous tutorial's code. Go ahead and skip ahead to the tutorials if you already know what I cover next. If you would like a little background information on movie clips and objects and how they relate to each other, then read on.

Requirements

To complete this tutorial you will need to install the following software and files:

Macromedia Flash MX 2004


or Macromedia Flash MX Professional 2004


Download sample files for this tutorial




About the author

Brian Lesser works at Ryerson University in Computing and Communications Services, where he has the ungainly title of Assistant Director, Teaching and Technology Support. Brian also teaches at Ryerson's School of Image Arts, contributed to Macromedia Flash MX ActionScript Bible (Hungry Minds, 2002), and coauthored Programming Flash Communication Server (forthcoming from O'Reilly & Associates).